<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/view/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>添加驻店信息</title>
	<link href="${contextPath}/styles/default.css" rel="stylesheet" type="text/css" />
	<script src="${contextPath}/scripts/jquery/jquery-1.8.3.min.js" type="text/javascript"></script>
	<script src="${contextPath}/scripts/scriptvalidator.js" type="text/javascript"></script>
	<script src="${contextPath}/scripts/linkage.js" type="text/javascript"></script>
<style type="text/css">
<!--
#apDiv1 {
	position:absolute;
	left:695px;
	top:95px;
	width:415px;
	height:161px;
	z-index:1;
}
-->
</style>
<script type="text/javascript">
$(document).ready(function(){
	//pc_init();
	//setProvCity("${province}","${city}");
});
</script>
</head>
<body onLoad="doAjaxTest('${brandId}')">
<div class="navigation">
	    <span><a href="javascript:window.history.back();"><img src="${contextPath}/images/back_nav_btn.png" /></a>
	    <a href="javascript:window.history.back();">返回</a>
	    <a href="javascript:window.history.forward();"><img src="${contextPath}/images/go_nav_btn.png" /></a>
	     <a href="javascript:window.history.forward();">前进</a>
	    <a href="javascript:window.location.reload();"><img src="${contextPath}/images/refresh_nav_btn.png" /></a>
	     <a href="javascript:window.location.reload();">刷新</a>
	    </span>系统管理&gt;&gt;驻店管理&gt;&gt;驻店修改
    </div>
<div class="xt_main_right_center">
  <form name="form1"  onsubmit="return checkSubmit();"  method="post" action="../shop/shopInsertAction.do?search.id=${search.id}">
  <input type="hidden" name="redirectUrl" value='<s:property value='redirectUrl'/>'/>
  <table width="1147" height="172" border="0">
    <tr>
      <td class="left-td-width-bg" align="right"><font  color="red" size="2">* </font>店号：</td>
      <td class="right-td-width-bg-left"><input  class="input" dataType="Require"  msg="店号不能为空" classType="com.jysz.certificate.persistence.model.system.Shop" ignoreCase="true"  valProperty="shopMark" entityId="${search.id}" contextPath="${contextPath}"  type="text" name="search.shopMark" value="${search.shopMark }" id="search.shopMark"></td>
      <td  class="left-td-width-bg" align="right">省：</td>
      <td class="right-td-width-bg-left" rowspan="2" >
		<!-- <select name="province"></select> -->
		<s:if test="provinces!=null">
	      <s:doubleselect list="provinces" listKey="id" listValue="name" name="province" 
	      value="province" doubleName="city" 
	      doubleList="top.childs" doubleListKey="id" doubleListValue="name" 
	       formName="form1" headerKey="" headerValue="请选择省份" 
	       doubleHeaderKey="" doubleHeaderValue="请选择市"
	       doubleValue="city"
	      theme="simple">
	      </s:doubleselect>
      </s:if>
	</td>
    </tr>
    <tr>
      <td  class="left-td-width-bg" align="right"><font  color="red" size="2">* </font>店名：</td>
      <td class="right-td-width-bg-left"><input dataType="Require"  msg="店名不能为空" classType="com.jysz.certificate.persistence.model.system.Shop" valProperty="shopName" entityId="${search.id}" contextPath="${contextPath}" class="input"  type="text" name="search.shopName" value="${search.shopName}" id="shopName"></td>
      <td  class="left-td-width-bg" align="right">市：</td>
      <!-- <td class="right-td-width-bg-left">
      <select name="city"></select> 
     </td> -->
    </tr>
    <tr>
      <td class="left-td-width-bg" align="right"><font  color="red" size="2">* </font>销售公司：</td>
      <td class="right-td-width-bg-left"><input dataType="Require"  msg="销售公司不能为空"  class="input"  type="text" name="search.company" value="${search.company }" id="search.company"></td>
     <td class="left-td-width-bg"  align="right">渠道：</td>
      <td  class="right-td-width-bg-left" >
			 <input name="textfield"  class="input" type="text" id="textfield" readonly="readonly" value="${branfName}">
        	<input name="brandId" style="display:none" type="text" id="brandId" readonly="readonly" value="${brandId}">
        	<a href="javascript:show()">选择</a>
	  </td> 
    </tr>
    <tr>
      <td class="left-td-width-bg" align="right">邮编：</td>
      <td class="right-td-width-bg-left"><input class="input"  type="text" name="search.postcode" value="${search.postcode }" id="search.postcode"></td>
      <td  class="left-td-width-bg" align="right">区域：</td>
      <td class="right-td-width-bg-left">
      	<select name="search.area.name" id="select2" onChange="doAjaxOrg('${search.id}')">
	      <option value="">****请选择****</option>
		<s:iterator value="domainshopList" status="i" id="b">
			<option <s:if test='search.area.name==#b.name'>selected="selected"</s:if>  value="${b.name }">${b.name }</option>
		</s:iterator>
       </select>
       </td>
    </tr>
    <tr>
      <td class="left-td-width-bg"  align="right">本月新增单价：</td>
      <td  class="right-td-width-bg-left" ><input dataType="Double" msg="请输入数字 "  class="input"  type="text" value="<s:property value="formatAmount(search.moneyStock)"/>" name="search.moneyStock" id="floors2"></td>
      <td class="left-td-width-bg"  align="right">上月结存单价：</td>
      <td  class="right-td-width-bg-left" ><input dataType="Double" msg="请输入数字 "  class="input"  type="text" value="<s:property value="formatAmount(search.moneyRemain)"/>" name="search.moneyRemain" id="floors5"></td>
    </tr>
     <tr>
      <td class="left-td-width-bg"  align="right">绩效保底数：</td>
      <td  class="right-td-width-bg-left" ><input dataType="Double" msg="请输入数字 "  class="input"  type="text" value="<s:property value="formatAmount(search.moneyRoyaltyTiny)"/>" name="search.moneyRoyaltyTiny" id="floors"></td>
      <td class="left-td-width-bg"  align="right">保底数递增：</td>
      <td  class="right-td-width-bg-left" ><input dataType="Double" msg="请输入数字 "  class="input"  type="text" value="<s:property value="formatAmount(search.moneyRoyaltyAdding)"/>" name="search.moneyRoyaltyAdding" id="floors4"></td>
    </tr>
    <tr>
      <td class="left-td-width-bg"  align="right">独立开票保底数：</td>
      <td  class="right-td-width-bg-left" ><input dataType="Double" msg="请输入数字 "  class="input"  type="text" value="<s:property value="formatAmount(search.moneyIndTiny)"/>" name="search.moneyIndTiny" id="floors3"></td>
      <td class="left-td-width-bg"  align="right">独立开票递增：</td>
      <td  class="right-td-width-bg-left" ><input dataType="Double" msg="请输入数字 "  class="input"  type="text" value="<s:property value="formatAmount(search.moneyIndBig)"/>" name="search.moneyIndBig" id="floors6"></td>
    </tr>
    <tr>
      <td rowspan="2"  align="right" class="left-td-width-bg">地址：</td>
      <td rowspan="2"  class="right-td-width-bg-left" ><textarea class="input"  name="search.address" cols="30" rows="7" id="search.address">${search.address }</textarea>       </td>
      <td class="left-td-width-bg"  align="right">默认渠道：</td>
      <td  class="right-td-width-bg-left" ><select class="select" name="search.defaultBrand.id" id="select">
        <option value="${search.defaultBrand.id }" selected>${search.defaultBrand.name }</option>
      </select></td>
    </tr>
    <tr>
      <td class="left-td-width-bg"  align="right">是否启用：</td>
      <td  class="right-td-width-bg-left" > 
      	<select name="search.toDelete" id="toDelete">
          <option value="1"  <s:if test='search.toDelete==1'>selected="selected"</s:if> >启用</option>
          <option value="0" <s:if test='search.toDelete==0'>selected="selected"</s:if>>禁用</option>
        </select></td>
    </tr>
    <tr>
      <td colspan="4" align="left">绩效计算公式：<br/><font  color="red" size="2">
     	 银行保底金额 计算方式 :"银行保底数(绩效保底数)+银行保底数递增(保底数)*(银行数量) + 金融机构保底数（业务逻辑上为0）* 金融机构保底数提成*(金融机构数量)"<br/>
     	 驻店员绩效计算方式 ：”独立开票递增 大于 ’本月库存数量*本月在库单价(本页的设置数)+上月在库数*上月结存单价(本页的设置数)‘ 取银行保底金额“<br/>
      	区域经理绩效绩效计算方式：本月库存数量*本月在库单价(本页的设置数)+上月在库数*上月结存单价(本页的设置数)</font></td>
    </tr>
    <tr>
      <td colspan="4" align="center">
      <input type="submit"  class="btn_save"  name="button" id="button" value="">
      </td>
    </tr>
  </table>
</form> 
</div>
<br/><br/><br/><br/><br/>
		<div><jsp:include page="/include/footer.inc"></jsp:include></div>
<script type="text/javascript">
function jumpPage(page) {
	var searchForm = document.searchForm;
	searchForm.action = "<s:property value='contextPath'/>/system/treaty/add.do?currentPage=" + page;
	searchForm.submit();
}
function checkSubmit(){
 	var staffForm = document.form1;
	if(!Validator.Validate(staffForm, 3)) {
		return false;
	}
		return true;
	
 }
function show(){
	var bId = document.getElementById("brandId").value;
	window.open("brandAll.do?brandId="+bId, "newwindow", "height=950, width=1000, toolbar =no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");
	}
function selectShopCallBack(name,bId){
	 document.getElementById("textfield").value=name;
	document.getElementById("brandId").value=bId;
	this.doAjaxTest(bId);
}
function doAjaxTest(i){
	if(i != null){
		var select=document.getElementById("select");
	    select.length=0;
		$.ajax({
			  async:false,
			  type: 'POST',
			  url:"<s:property value='contextPath'/>/system/shop/detailsBrand.do?brandId="+i,
			  dataType: "json",
			  success: function(data) {
				  if(data !=null){
					  var obj=document.getElementById("select");
					  obj.options.length=0;
					  var a=new Array();
					  var b=new Array();  
					  a = data.toString().split(",");
					  for(var i=0;i<a.length;i++){
						  b = a[i].split(":");
						  obj.options.add(new Option(b[1],b[0]));
					  }
				  }
				  
			  }
			});
	}
	
}
var booler= true;
//更改区域判断是否还有驻店员
function doAjaxOrg(i){
	if(i != null){
		$.ajax({
			  async:false,
			  type: 'POST',
			  url:"<s:property value='contextPath'/>/system/shop/judgeOrg.do?id="+i,
			  dataType: "json",
			  success: function(data) {
				  if(data){
					  alert("该店在组织架构中还存在监管人员，请先删除人员后，在修改其区域");
					  booler = false;
				  }
			  }
			});
	}
	
}
</script>
</body>
</html>